package com.shoesdemo.activity;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.shoesdemo.BaseActivity;
import com.shoesdemo.R;
import com.shoesdemo.view.LevelSelectView;

public class SettingTomorrowActivity extends BaseActivity implements View.OnClickListener {

    private TextView mTvTheme1;
    private TextView mTvTheme2;
    private TextView mTvTheme3;
    private LevelSelectView mLsvWork;
    private LevelSelectView mLsvReleasr;
    private int workTime = 10;
    private int releaseTime = 10;
    private int type = 1;

    @Override
    protected void initView() {
        mView.setBackgroundColor(getResources().getColor(R.color.color_black));
        setTitle("自定义番茄");
        findViewById(R.id.start).setOnClickListener(this);
        mTvTheme1 = findViewById(R.id.tv_theme_1);
        mTvTheme2 = findViewById(R.id.tv_theme_2);
        mTvTheme3 = findViewById(R.id.tv_theme_3);
        mLsvWork = findViewById(R.id.lsv_work);
        mLsvReleasr = findViewById(R.id.lsv_release);
    }

    @Override
    protected void initListener() {
        mTvTheme1.setOnClickListener(this);
        mTvTheme2.setOnClickListener(this);
        mTvTheme3.setOnClickListener(this);
        mLsvWork.setOnPosClickListener(new LevelSelectView.OnPosClickListener() {
            @Override
            public void onClickListener(int position) {
                switch (position) {
                    case 0:
                        workTime = 10;
                        break;
                    case 1:
                        workTime = 25;
                        break;
                    case 2:
                        workTime = 40;
                        break;
                    case 3:
                        workTime = 55;
                        break;
                }
            }
        });
        mLsvReleasr.setOnPosClickListener(new LevelSelectView.OnPosClickListener() {
            @Override
            public void onClickListener(int position) {
                switch (position) {
                    case 0:
                        releaseTime = 10;
                        break;
                    case 1:
                        releaseTime = 15;
                        break;
                    case 2:
                        releaseTime = 20;
                        break;
                    case 3:
                        releaseTime = 25;
                        break;
                }
            }
        });
    }

    @Override
    public int getLayoutView() {
        return R.layout.activity_categary_tomorrow;
    }

    @Override
    protected void initData() {

    }

    @Override
    public void onClick(View v) {
//        workTime=1;
//        releaseTime=1;
        switch (v.getId()) {
            case R.id.start:
                if (type == 1) {
                    TomorrowActivity.start(this, workTime, releaseTime);
                }
                if (type == 2) {
                    ElectActivity.start(this, workTime, releaseTime);
                }
                if (type == 3) {
                    TextTomorrowActivity.start(this, workTime, releaseTime);
                }
                break;
            case R.id.tv_theme_1:
                type = 1;
                updateView(1);
                break;
            case R.id.tv_theme_2:
                type = 2;
                updateView(2);
                break;
            case R.id.tv_theme_3:
                type = 3;
                updateView(3);
                break;
        }
    }

    private void updateView(int pos) {
        if (pos == 1) {
            mTvTheme1.setBackground(getDrawable(R.drawable.clock_theme_check));
            mTvTheme1.setTextColor(getResources().getColor(R.color.color_058AEC));
            mTvTheme2.setBackground(getDrawable(R.drawable.clock_theme_uncheck));
            mTvTheme2.setTextColor(getResources().getColor(R.color.color_white));
            mTvTheme3.setBackground(getDrawable(R.drawable.clock_theme_uncheck));
            mTvTheme3.setTextColor(getResources().getColor(R.color.color_white));
        }
        if (pos == 2) {
            mTvTheme1.setBackground(getDrawable(R.drawable.clock_theme_uncheck));
            mTvTheme1.setTextColor(getResources().getColor(R.color.color_white));
            mTvTheme2.setBackground(getDrawable(R.drawable.clock_theme_check));
            mTvTheme2.setTextColor(getResources().getColor(R.color.color_058AEC));
            mTvTheme3.setBackground(getDrawable(R.drawable.clock_theme_uncheck));
            mTvTheme3.setTextColor(getResources().getColor(R.color.color_white));
        }
        if (pos == 3) {
            mTvTheme1.setBackground(getDrawable(R.drawable.clock_theme_uncheck));
            mTvTheme1.setTextColor(getResources().getColor(R.color.color_white));
            mTvTheme2.setBackground(getDrawable(R.drawable.clock_theme_uncheck));
            mTvTheme2.setTextColor(getResources().getColor(R.color.color_white));
            mTvTheme3.setBackground(getDrawable(R.drawable.clock_theme_check));
            mTvTheme3.setTextColor(getResources().getColor(R.color.color_058AEC));
        }
    }
}
